﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class edutestquestions : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    //提交信息
    //protected void btnpaper_Click(object sender, EventArgs e)
    //{
    //    SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["smsConnectionString"].ConnectionString);

    //    SqlDataAdapter da = new SqlDataAdapter("select * from CourseInfo", objConnection);
    //    SqlCommandBuilder cb = new SqlCommandBuilder(da);

    //    DataSet ds = new DataSet();
    //    da.Fill(ds, "CourseInfo");
    //    DataTable dt = ds.Tables["CourseInfo"];

    //    DataRow[] rows = dt.Select("CourseID = "+this.DropDownList3.SelectedValue+"");
    //    foreach(DataRow row in rows)
    //    {
    //        //row["ExamAllTime"] = ?
    //        row["PassQuestionNum"] = this.WebNumericEdit1.Value;
    //        row["QuestionAllNum"] = this.WebNumericEdit2.Value;
    //    }

    //    da.Update(dt);

    //    PageRebush();
    //}

    ////导出试卷
    //protected void btnprintertest_Click(object sender, EventArgs e)
    //{
    //    PageRebush();
    //}

    
    //public void PageRebush()
    //{
    //    this.WebNumericEdit1.Text ="";
    //    this.WebNumericEdit2.Text = "";
    //    this.Lbltestqm.Text = "";
    //}
   
   
    public static string GetNavigateUrl(Object item1)
    {
        int nID = (int)System.Web.UI.DataBinder.Eval(item1, "CourDocumentID");

        string result = "~/ShowFile.aspx?ID=";
        result += nID;
        return result;
    }

    public static string GetNavigateUrlEdit(Object item1, Object item2)
    {
        int nID = (int)System.Web.UI.DataBinder.Eval(item1, "CourDocumentID");

        string result = "~/eduExamquestion.aspx?FileID=" + nID + "";
        return result;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/edueditmatter.aspx");
    }
    
    //删除
    protected void Button2_Click1(object sender, EventArgs e)
    {
        SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["smsConnectionString"].ConnectionString);

        SqlDataAdapter da = new SqlDataAdapter("select * from CourseDocumentInfo", objConnection);
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        DataSet ds = new DataSet();
        da.Fill(ds, "CourseDocumentInfo");
        DataTable dt = ds.Tables["CourseDocumentInfo"];
        DataRow[] rows = dt.Select("CourDocumentID = " + Convert.ToInt32(this.UltraWebGrid1.DisplayLayout.ActiveRow.DataKey) + "");
        foreach (DataRow row in rows)
            row["IsDeleted"] = true;
        da.Update(dt);

        SetData();
    }

    public void SetData()
    {
        ConnectionStringSettings connObj = ConfigurationManager.ConnectionStrings["smsConnectionString"];
        string connectionString = connObj.ConnectionString;
        SqlConnection objConnection = new SqlConnection(connectionString);

        SqlDataAdapter da = new SqlDataAdapter("SELECT CourDocumentID, CourDocumentName AS 课程资料 FROM CourseDocumentInfo WHERE (IsDeleted <> 1) ORDER BY CourDocumentUploadDate DESC", objConnection);

        DataSet ds = new DataSet();
        da.Fill(ds, "CourseDocumentInfo");
        DataTable dt = ds.Tables["CourseDocumentInfo"];
        DataView view = new DataView(dt);

        this.UltraWebGrid1.DataSource = view;
        this.UltraWebGrid1.DataKeyField = "CourDocumentID";
        this.UltraWebGrid1.DataBind();
        //this.UltraWebGrid1.Columns[1].Hidden = true;

    }
}
